package com.server.http.handler.impl;
/**
* @author	李小布
* @email	397554852@qq.com
* @version	创建时间：2018年8月31日 上午10:32:18
*/

import java.util.HashMap;
import java.util.Map;

import com.server.conditionenum.HttpReturnStatus;
import com.server.http.handler.HttpHandler;
import com.server.http.request.HttpRequestMessage;
import com.server.http.response.HttpResponseMessage;
import com.server.mine.net.HttpProtocol;
import com.server.tools.AppData;

public class GetSwitch extends HttpHandler{

	@Override
	public void handle(HttpRequestMessage request, HttpResponseMessage response) {
		String failMsg = null;
		Map<String, Object> data = new HashMap<String,Object>();
		long appid = 0;
		try {
			appid = Long.parseLong(request.getParameter("appid"));
			if(AppData.appSwitchMap.containsKey(appid)) {
				data.put("switch_1", AppData.appSwitchMap.get(appid).switch_1);
				data.put("switch_2", AppData.appSwitchMap.get(appid).switch_2);
				data.put("switch_3", AppData.appSwitchMap.get(appid).switch_3);
				data.put("switch_4", AppData.appSwitchMap.get(appid).switch_4);
				data.put("switch_5", AppData.appSwitchMap.get(appid).switch_5);
			}else {
				failMsg = "appid不存在!";
			}
			
		}catch (Exception e) {
			e.printStackTrace();
			failMsg = "上传的参数错误!";
		}
		if(failMsg == null) {
			SetReturnData(response,data,HttpProtocol.GETSWITCH,HttpReturnStatus.Successed);
		}else {
			SetReturnData(response,failMsg,HttpProtocol.GETSWITCH,HttpReturnStatus.Failed);
		}
	}
}